package com.roger.myHome.controller;

import com.roger.myHome.aspect.WebLog;
import com.roger.myHome.entity.dto.FinancialAddReq;
import com.roger.myHome.entity.dto.LotteryAddReq;
import com.roger.myHome.entity.qto.LotteryQTO;
import com.roger.myHome.page.EUDataGridResult;
import com.roger.myHome.service.LotteryService;
import com.roger.myHome.util.BaseUtil;
import com.roger.myHome.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/lottery")
@Slf4j
public class LotteryController {
    @Resource
    private LotteryService lotteryService;

    @PostMapping("/page")
    public EUDataGridResult page(@RequestParam(value="page",required=false) String page,
                                 @RequestParam(value="rows",required=false) String rows, HttpServletRequest req) {

        LotteryQTO qryReq = new LotteryQTO();
        qryReq.setPage((Integer.parseInt(page) - 1) * Integer.parseInt(rows));
        qryReq.setRows(Integer.parseInt(rows));

        return lotteryService.page(qryReq);
    }

    @PostMapping("/add")
    public String add(HttpServletRequest req, LotteryAddReq addReq){
        String result = null;
        log.info("{}", addReq);

        return lotteryService.add(addReq);
    }

}
